/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentaPPal.java
 *
 * Created on 31-ago-2011, 1:04:00
 */
package Ventanas;

import Objetos.PropiedadesIP;
import Proxies.CtrlInicioSesionWS;
import Proxies.CtrlInicioSesionWSService;
import Proxies.CtrlJuegoDatosWS;
import Proxies.CtrlJuegoDatosWSService;
import Proxies.CtrlRelojSistemaWS;
import Proxies.CtrlRelojSistemaWSService;
import java.awt.HeadlessException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.xml.namespace.QName;

/**
 *
 * @author Sebas
 */
public class VentaPPal extends javax.swing.JFrame {

    public VentaPPal(String title) throws HeadlessException {
        super(title);
        initComponents();
    }

    /** Creates new form VentaPPal */
    public VentaPPal() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        ListarUsuarios = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("RED(Estación de trabajo) - Ventana principal");

        jButton1.setText("Modificar Usuario");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jButton2.setText("Alta Usuario");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("ESTACION DE TRABAJO");

        jButton3.setText("Crear Grupo");
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        jButton4.setText("Agregar/Quitar miembros de Grupo");
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton4MouseClicked(evt);
            }
        });

        jButton5.setText("Agregar Amistad");
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton5MouseClicked(evt);
            }
        });

        jButton6.setText("Agregar moderadores de Grupo");
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton6MouseClicked(evt);
            }
        });

        jButton7.setText("Agregar juego de datos");
        jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton7MouseClicked(evt);
            }
        });

        jButton8.setText("Cerrar Sesión");
        jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton8MouseClicked(evt);
            }
        });

        jButton9.setText("Bloquear usuario");
        jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton9MouseClicked(evt);
            }
        });

        ListarUsuarios.setText("ListarUsuarios");
        ListarUsuarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ListarUsuariosMouseClicked(evt);
            }
        });

        jButton10.setText("Ver Detalle de Grupo");
        jButton10.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton10MouseClicked(evt);
            }
        });

        jButton11.setText("Crear Eventos");
        jButton11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton11MouseClicked(evt);
            }
        });

        jButton12.setText("Agregar entrada a Muro");
        jButton12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton12MouseClicked(evt);
            }
        });

        jMenu1.setText("File");

        jMenuItem2.setText("Cerrar Sesion");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem1.setText("Exit");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Reloj del sistema");
        jMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });

        jMenuItem3.setText("Consultar fecha");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(99, 99, 99)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jButton7)
                    .addComponent(jButton9)
                    .addComponent(jButton8)
                    .addComponent(jButton1)
                    .addComponent(ListarUsuarios)
                    .addComponent(jButton2)
                    .addComponent(jButton10)
                    .addComponent(jButton3)
                    .addComponent(jButton4)
                    .addComponent(jButton5)
                    .addComponent(jButton6)
                    .addComponent(jButton11)
                    .addComponent(jButton12)
                    .addComponent(jLabel1))
                .addContainerGap(81, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton7)
                .addGap(2, 2, 2)
                .addComponent(jButton9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ListarUsuarios)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton12)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
        // TODO add your handling code here:
        CrearGrupo cg = new CrearGrupo();
        cg.setVisible(true);
        cg.setLocationRelativeTo(null);
    }//GEN-LAST:event_jButton3MouseClicked

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        // TODO add your handling code here:
        AltaUsuario altaUsr = new AltaUsuario();
        altaUsr.setLocationRelativeTo(null);
        altaUsr.setVisible(true);

    }//GEN-LAST:event_jButton2MouseClicked

    private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
        // TODO add your handling code here:
        ModificarMiemGrupo mm = new ModificarMiemGrupo();
        mm.setVisible(true);
        mm.setLocationRelativeTo(null);
    }//GEN-LAST:event_jButton4MouseClicked

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        // TODO add your handling code here:
        ModificarUsuario2 mu = new ModificarUsuario2();
        mu.setVisible(true);
        mu.setLocationRelativeTo(null);
    }//GEN-LAST:event_jButton1MouseClicked

private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
// TODO add your handling code here:

    Amistades am = new Amistades();
    am.setVisible(true);
    am.setLocationRelativeTo(null);

}//GEN-LAST:event_jButton5MouseClicked

private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseClicked
    // TODO add your handling code here:
    AgregarModeradores am = new AgregarModeradores();
    am.setLocationRelativeTo(null);
    am.setVisible(true);
}//GEN-LAST:event_jButton6MouseClicked

private void jButton7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseClicked
    // TODO add your handling code here:
    PropiedadesIP props = PropiedadesIP.getInstance();
    String IP = props.getServidorCentralIP();
    URL dirJuego = null;
    try {
        dirJuego = new URL(IP + "CtrlJuegoDatos?wsdl");
    } catch (MalformedURLException ex) {
        Logger.getLogger(VentaPPal.class.getName()).log(Level.SEVERE, null, ex);
    }
    QName qNaJuego = new QName("http://WebServices/", "CtrlJuegoDatosWSService");
    CtrlJuegoDatosWS ctrlJuego = new CtrlJuegoDatosWSService(dirJuego, qNaJuego).getCtrlJuegoDatosWSPort();
    
    ctrlJuego.agregarJuego();
    JOptionPane.showMessageDialog(null, "Se agregó el juego de datos la sistema");
}//GEN-LAST:event_jButton7MouseClicked

private void jButton8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseClicked
    // TODO add your handling code here:

    PropiedadesIP props = PropiedadesIP.getInstance();
    String IP = props.getServidorCentralIP();
    URL dirInicio = null;
    try {
        dirInicio = new URL(IP + "CtrlInicioSesion?wsdl");
    } catch (MalformedURLException ex) {
        Logger.getLogger(VentaPPal.class.getName()).log(Level.SEVERE, null, ex);
    }
    QName qNaInicio = new QName("http://WebServices/", "CtrlInicioSesionWSService");
    
    CtrlInicioSesionWS ctrlInicio = new CtrlInicioSesionWSService(dirInicio, qNaInicio).getCtrlInicioSesionWSPort();
    int confirma = JOptionPane.showConfirmDialog(null, "Confirma que desea cerrar sesión de administrador?", "Cerrar sesión", JOptionPane.YES_NO_OPTION);
    if (confirma == 0) {
        ctrlInicio.logout();
        Login log = new Login();
        setVisible(false);
        log.setVisible(true);
        log.setLocationRelativeTo(null);
    }

}//GEN-LAST:event_jButton8MouseClicked

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
    // TODO add your handling code here:
    int confirma = JOptionPane.showConfirmDialog(null, "Confirma que desea salir de la aplicacion?", "Cerrar aplicación", JOptionPane.YES_NO_OPTION);
    if (confirma == 0) {
        System.exit(0);
    }

}//GEN-LAST:event_jMenuItem1ActionPerformed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    // TODO add your handling code here:
    PropiedadesIP props = PropiedadesIP.getInstance();
    String IP = props.getServidorCentralIP();
    URL dirInicio = null;
    try {
        dirInicio = new URL(IP + "CtrlInicioSesion?wsdl");
    } catch (MalformedURLException ex) {
        Logger.getLogger(VentaPPal.class.getName()).log(Level.SEVERE, null, ex);
    }
    QName qNaInicio = new QName("http://WebServices/", "CtrlInicioSesionWSService");
    
    CtrlInicioSesionWS ctrlInicio = new CtrlInicioSesionWSService(dirInicio, qNaInicio).getCtrlInicioSesionWSPort();
    int confirma = JOptionPane.showConfirmDialog(null, "Confirma que desea cerrar sesión de administrador?", "Cerrar sesión", JOptionPane.YES_NO_OPTION);
    if (confirma == 0) {
        ctrlInicio.logout();
        Login log = new Login();
        setVisible(false);
        log.setVisible(true);
        log.setLocationRelativeTo(null);
    }
}//GEN-LAST:event_jMenuItem2ActionPerformed

private void jButton9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton9MouseClicked
    // TODO add your handling code here:
    BloqueoUsuario bUsr = new BloqueoUsuario();
    bUsr.setVisible(true);
    bUsr.setLocationRelativeTo(null);
}//GEN-LAST:event_jButton9MouseClicked

private void ListarUsuariosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ListarUsuariosMouseClicked
// TODO add your handling code here:
    ListarUsuarios bUsr = new ListarUsuarios();
    bUsr.setVisible(true);
    bUsr.setLocationRelativeTo(null);
}//GEN-LAST:event_ListarUsuariosMouseClicked

private void jButton10MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton10MouseClicked
    // TODO add your handling code here:
    DetalleGrupo dg = new DetalleGrupo();
    dg.setVisible(true);
    dg.setLocationRelativeTo(null);
}//GEN-LAST:event_jButton10MouseClicked

    private void jButton11MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton11MouseClicked
        // TODO add your handling code here:
        AgregarEventos ev = new AgregarEventos();
        ev.setVisible(true);
        ev.setLocationRelativeTo(null);

    }//GEN-LAST:event_jButton11MouseClicked

    private void jButton12MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton12MouseClicked
        // TODO add your handling code here:
        AgregarEntradaMuro amuro = new AgregarEntradaMuro();
        amuro.setVisible(true);
        amuro.setLocationRelativeTo(null);
    }//GEN-LAST:event_jButton12MouseClicked

    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        PropiedadesIP props = PropiedadesIP.getInstance();
        String IP = props.getServidorCentralIP();
        
        URL dirReloj = null;
        try {
            dirReloj = new URL(IP + "CtrlRelojSistema?wsdl");
        } catch (MalformedURLException ex) {
            Logger.getLogger(VentaPPal.class.getName()).log(Level.SEVERE, null, ex);
        }
        QName qNaReloj = new QName("http://WebServices/", "CtrlRelojSistemaWSService");
            
        CtrlRelojSistemaWS ctrl = new CtrlRelojSistemaWSService(dirReloj, qNaReloj).getCtrlRelojSistemaWSPort();

        Calendar tiempo = ctrl.getTime().toGregorianCalendar();
        String strTiempo = "hh:mm:ss\n"
                + tiempo.get(Calendar.HOUR) + ":"
                + tiempo.get(Calendar.MINUTE) + ":"
                + tiempo.get(Calendar.SECOND);
        JOptionPane.showMessageDialog(null, strTiempo, "Fecha del sistema", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jMenuItem3ActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new VentaPPal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ListarUsuarios;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    // End of variables declaration//GEN-END:variables
}
